<?php
declare(strict_types=1);

use Hyperf\HttpServer\Router\Router;

Router::addGroup('/api/v1/',function (){
    Router::get('test/index','App\Controller\Api\V1\TestController@index');
    Router::get('test/home','App\Controller\Api\V1\TestController@home');

    Router::addGroup('home/',function(){
        //首页数据
        Router::get('index','App\Controller\Api\V1\Home\IndexController@index');
    },[]);

    Router::addGroup('auth/',function(){
        //手机一键登录
        Router::post('login/phone','App\Controller\Api\V1\AuthController@loginByPhone');
        //微信登录
        Router::post('login/wechat','App\Controller\Api\V1\AuthController@loginByWechat');
        Router::post('login/wechat/authorization','App\Controller\Api\V1\AuthController@loginByAuthorization');
        //微信测试登录
        Router::post('login/wechat/test','App\Controller\Api\V1\AuthController@loginByWechatTest');

        Router::post('wechat/init','App\Controller\Api\V1\AuthController@wechatCheckUser');

        Router::post('refresh-token','App\Controller\Api\V1\AuthController@refreshToken');

        Router::post('user/sync','App\Controller\Api\V1\AuthController@userSync');

        Router::post('bind-phone','App\Controller\Api\V1\AuthController@bindPhone',['middleware'=>[
            \App\Middleware\UserJwtAuthMiddleware::class
        ]]);
        Router::post('bind-phone-test','App\Controller\Api\V1\AuthController@bindPhoneTest',['middleware'=>[
            \App\Middleware\UserJwtAuthMiddleware::class
        ]]);
    },[]);

    Router::addGroup('common/',function() {
        Router::addGroup('config/',function(){
            Router::get('get/value','App\Controller\Api\V1\Common\ConfigController@getValue');
        });
        Router::addGroup('sms/',function(){
            Router::post('send','App\Controller\Api\V1\Common\SmsController@send');
        });

        Router::addGroup('area/',function(){
            Router::post('all','App\Controller\Api\V1\Common\AreaController@all');
            Router::post('street','App\Controller\Api\V1\Common\AreaController@street');
            Router::post('community','App\Controller\Api\V1\Common\AreaController@community');
        });

        Router::addGroup('file/',function(){
            Router::post('upload','App\Controller\Api\V1\Common\FileController@upload',['middleware'=>[
                //\App\Middleware\UserJwtAuthMiddleware::class
            ]]);
            Router::post('qiniu/token','App\Controller\Api\V1\Common\FileController@getQiniuToken',['middleware'=>[
                //\App\Middleware\UserJwtAuthMiddleware::class
            ]]);
        });
    });

    Router::addGroup('position/',function() {
        Router::addGroup('supervisor/',function(){
            Router::post('apply','App\Controller\Api\V1\PositionSupervise\SupervisorController@apply');
            Router::post('my/position','App\Controller\Api\V1\PositionSupervise\SupervisorController@myPosition');
            Router::post('positions','App\Controller\Api\V1\PositionSupervise\SupervisorController@positions');
        },['middleware'=>[
            \App\Middleware\UserJwtAuthMiddleware::class
        ]]);
        Router::post('category/all','App\Controller\Api\V1\PositionSupervise\CategoryController@all',['middleware'=>[
            \App\Middleware\UserJwtAuthMiddleware::class
        ]]);
        Router::addGroup('paper/',function(){
            Router::post('detail','App\Controller\Api\V1\PositionSupervise\PaperController@detail');
            Router::post('submit','App\Controller\Api\V1\PositionSupervise\PaperController@submit');
            Router::post('mine','App\Controller\Api\V1\PositionSupervise\PaperController@mine');
            Router::post('answer/detail','App\Controller\Api\V1\PositionSupervise\PaperController@answerDetail');
        },['middleware'=>[
            \App\Middleware\UserJwtAuthMiddleware::class
        ]]);
    });

    /**
     * 问卷
     */
    Router::addGroup('paper/',function(){
        Router::post('list','App\Controller\Api\V1\Paper\PaperController@list');
        Router::post('detail','App\Controller\Api\V1\Paper\PaperController@detail');
        Router::post('submit','App\Controller\Api\V1\Paper\PaperController@submit');
        Router::post('mine','App\Controller\Api\V1\Paper\PaperController@mine');
        Router::post('answer/detail','App\Controller\Api\V1\Paper\PaperController@answerDetail');
    },['middleware'=>[
        \App\Middleware\UserJwtAuthMiddleware::class
    ]]);



    Router::addGroup('cms/',function() {
        Router::addGroup('help/',function(){
            Router::get('list','App\Controller\Api\V1\Cms\HelpController@list');
        });
        Router::addGroup('category/',function(){
            Router::get('all','App\Controller\Api\V1\Cms\CategoryController@all');
        });
        Router::addGroup('article/',function(){
            Router::get('list','App\Controller\Api\V1\Cms\ArticleController@list');
            Router::get('show','App\Controller\Api\V1\Cms\ArticleController@show');
            Router::get('page','App\Controller\Api\V1\Cms\ArticleController@page');
        });
    });

    Router::addGroup('ad/',function() {
        Router::addGroup('data/',function(){
            Router::post('list','App\Controller\Api\V1\Ad\DataController@list');
        });
    });

    Router::addGroup('user/',function(){
        Router::post('home','App\Controller\Api\V1\User\UserController@home');
        Router::post('check/supervisor','App\Controller\Api\V1\User\UserController@checkSupervisor');
        Router::get('account','App\Controller\Api\V1\User\UserController@account');
    },['middleware'=>[
        \App\Middleware\UserJwtAuthMiddleware::class
    ]]);
},['middleware'=>[
    \App\Middleware\UserJwtGetMiddleware::class,
    \App\Middleware\ApiCheckMiddleware::class
]]);

Router::addGroup('/api/v2/',function (){
},['middleware'=>[
    \App\Middleware\UserJwtGetMiddleware::class,
    //\App\Middleware\ApiCheckMiddleware::class
]]);